const app = getApp();
Page({
  data: {
    who: ''
  },

  goto_stu_info: function (e) {
    var userid = wx.getStorageSync('openid'); //获取到用户的openid
    console.log(userid)
    wx.request({
      url: app.globalData.ServerUrl + 'stu_info.php',
      data: {
        userid: userid
      },
      method: 'POST',
      header: {
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res.data)
        if (res.data == "not_null") {
          wx.reLaunch({
            url: '../home/home/home?who=0'
          })
          console.log("数据库中存在该用户")
        } else {
          wx.navigateTo({
            url: '../info/stu/stu',
          })
          console.log("前往注册")
        }
      },
      fail: function (res) {},
      complete: function (res) {},
    })
  },

  goto_tea_info: function (e) {
    var userid = wx.getStorageSync('openid'); //获取到用户的openid
    console.log(userid)
    wx.request({
      url: app.globalData.ServerUrl + 'tea_info.php',
      data: {
        userid: userid
      },
      method: 'POST',
      header: {
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res.data)
        if (res.data == "not_null") {
          wx.reLaunch({
            url: '../home/home/home?who=1'
          })
          console.log("数据库中存在该用户")
        } else {
          wx.navigateTo({
            url: '../info/tea/tea',
          })
          console.log("前往注册")
        }
      },
      fail: function (res) {},
      complete: function (res) {},
    })
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }

})